/********************************************************************************
*                 Copyright (C) 2011 - Las Venturas Playground                  *
*                      http://iv-mp.nl | http://lvp-iv.com                      *
*                                                                               *
*    This program is free software: you can redistribute it and/or modify       *
*    it under the terms of the GNU General Public License as published by       *
*    the Free Software Foundation, either version 3 of the License, or          *
*    (at your option) any later version.                                        *
*                                                                               *
*    This program is distributed in the hope that it will be useful,            *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of             *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
*    GNU General Public License for more details.                               *
*                                                                               *
*    You should have received a copy of the GNU General Public License          *
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
*                                                                               *
*********************************************************************************
*                                                                               *
*  Las Venturas Playground - callbacks/onPlayerDisconnect.nut                   *
*                                                                               *
*  The onPlayerDisconnect callback is located here.                             *
*                                                                               *
********************************************************************************/

/**
 * This event is called when a user disconnects from the server.
 *
 * @param playerid The playerid that quit
 * @param reason The reason the user quit, 1 = timeout/crash, 0 is quit
 */
function onPlayerDisconnect( playerid, reason )
{
    // We set the disconnect reason.
    local DisconnectReason = "Quit";
    
    if (reason == 1)
    {
        DisconnectReason = "Timeout/Crash";
    }
    
    // Inform the rest of the players
    sendMessageToAll ("* " + getPlayerName(playerid) + " has left the server! (" + DisconnectReason + ")", COLOR_GREY);
    
    // Save the users data, quite important.
    SaveUserData (playerid);
    return 1;
}

addEvent("playerDisconnect", onPlayerDisconnect);